import {loginByUsername} from "@/api/login";

const user = {
  state : {
    uid : '',
    name : '',
    token : '',
    roles : []
  },
  mutations : {

  },
  actions : {
    LoginByUsername(context, userinfo) {
      return new  Promise( (resolve, reject) => {
        loginByUsername(userinfo.name, userinfo.password).then( response => {
          if(response.data.code == 0){
            reject();
          }else{
            resolve();
          }
        }).catch(err => {
          reject(err)
        })
      })
    },

  }
}


export default user;
